#ifndef CEXCEPTION_H_INCLUDED
#define CEXCEPTION_H_INCLUDED

/**
 *
 * \file CException.h
 * \brief This file contains the CException class declaration.
 * \author Vladimir Klubkov (aka marked)
 *
 * Last changes date:
 * \date 12.03.2011
 *
 * Copyright 2011 Vladimir Klubkov <marked-one@yandex.ru>
 *
 * This file is part of OOXlib.
 *
 * OOXLib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OOXlib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OOXlib; if not, you can try to find  it here:
 * http://www.gnu.org/licenses/gpl.txt
 * or write to the Free Software Foundation, Inc., 59 Temple Place,
 * Suite 330, Boston, MA  02111-1307  USA
 *
 */

/*
 * There are three types of errors, which can happen in OOXlib.
 * The first type are the OOXLib::CException exceptions, which base class
 * CException is declared in this file. To handle this type of errors you
 * must use catch(CException &Exception) {} or catch() with OOXlib::CException derived classes.
 * The second type of errors are the ::std::exception exceptions (STL exceptions).
 * To handle them, use catch(::std::exception &Exception) {} or catch with the ::std::exception derived classes.
 * The third type of errors are the X Errors. These are errors, which seemed to the xlib authors to be fatal -
 * wrong functon parameters, bad allocation etc. These errors are handled by the X Server.
 * When one of these errors happens, the program terminates, and information about the error is
 * printed to the terminal.
 */

#include "includes.h"

namespace OOXlib {

/**
 * \class CException
 * Exception handler class.
 * Can be used as a default exception handler
 * or as a base class for other exception handlers.
 */
class CException {
public:
    CException();
    CException(const ::std::string &File, const int iLine, const ::std::string &Function);
    CException(const ::std::string &File, const int iLine, const ::std::string &Function, const ::std::string &Description);
    CException(const ::std::string &File, const int iLine, const ::std::string &Function, const ::std::string &Description, const int iReturnValue);
    virtual ~CException();
    virtual ::std::string Description() const;
    virtual int ReturnValue() const;
protected:
    ::std::string m_Description;
    int m_iReturnValue;
};
/**
 * The main OOXlib throw replacement macro.
 * \param ctor_name Constructor name.
 */
#define OOXLib_THROW(ctor_name) throw ctor_name(__FILE__, __LINE__, __PRETTY_FUNCTION__)

} // OOXlib

#endif // CEXCEPTION_H_INCLUDED
